package com.moge.anjian.manager;


import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;

import com.moge.anjian.App;
import com.moge.anjian.beans.AutoTask;
import com.moge.anjian.utils.SpUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class RecordPlayManager {

    public static boolean isRecording;
    List<AutoTask> taskList;

    public static void startRecord() {
        AutoClickManager.getInstance().stopAutoClick();
        TargetManager.getInstance().cleanWindow();
        isRecording = true;
    }

    public void stopRecord(Context mContext) {
        isRecording = false;
        Dialog dialog = new AlertDialog.Builder(mContext)
                .setTitle("录制结束")
                .setMessage("是否保存本次录制?")
                .setNegativeButton("放弃", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setPositiveButton("保存", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                })
                .create();
    }

    public void addEvent(AutoTask task) {
        if (taskList == null) {
            taskList = new ArrayList<>();
        }
        taskList.add(task);
    }

    public void saveTask() {
        SpUtils.putString(new Date().toString(), taskList.toString());
    }

    public void deleteTask(String taskKey) {
        SpUtils.remove(App.get(), taskKey);
    }

}
